#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int majorityElement(vector<int>& nums)
{
  int ret=0;
  int ln=1;
  int len=nums.size();
  len/=2;
  if(0==len)
    return nums.at(0);
  std::sort(nums.begin(), nums.end());
  for(std::vector<int>::iterator iter=nums.begin();
      iter!=nums.end();++iter)
  {
    if( *iter == *(iter+1) )
    {
      ln++;
      if( ln>len )
      {
        ret=*iter;
        return ret;
      }

    }
    else
    {
      ln=1;
    }
  }


  //return ret;    
}

int main( int argc,char * argv[] )
{

  std::vector<int> nums;
  nums.push_back(5);
  nums.push_back(2);
  nums.push_back(3);
  nums.push_back(5);
  nums.push_back(1);
  nums.push_back(5);
  nums.push_back(5);

  int r=majorityElement(nums);
  cout<<r<<endl;


  return 0;

}
